package com.yun.algorithmproblem.leetcode;

public class Leetcode3099 {
    public static void main(String[] args) {
        Leetcode3099 obj = new Leetcode3099();
        System.out.println(obj.sumOfTheDigitsOfHarshadNumber(18));
    }

    public int sumOfTheDigitsOfHarshadNumber(int x) {
        int sum = 0;
        int original = x;
        while (x != 0) {
            sum += x % 10;
            x = x / 10;
        }
        return original % sum == 0 ? sum : -1;
    }
}
